package generator;

import java.io.Serializable;
import java.util.Comparator;
import misc.Vector3i;

public class TunnelPlacementComparator implements Comparator<TunnelPlacement>, Serializable {
    private static final long serialVersionUID = 1L;
    protected Vector3i goal;

    @Deprecated
    protected TunnelPlacementComparator() {}
    
    public TunnelPlacementComparator(Vector3i goal) {
        this.goal = goal;
    }
    
    public int compare(TunnelPlacement o1, TunnelPlacement o2) {
	if(o1.equals(o2))
	    return 0;
        //Below is the heuristic for the tunnel placement algorithm
        int estCost1 = o1.getCost() + DungeonGenerator.bestCostBetween(o1.getLocation(), goal);
        int estCost2 = o2.getCost() + DungeonGenerator.bestCostBetween(o2.getLocation(), goal);
	if(estCost1 < estCost2)
	    return -1;
	else if(estCost1 > estCost2)
	    return 1;
	else
	    return 0;
    }
}
